* merge county-level wind with county-level worker data

* merge in establishment and wind data together at county level
*import sas using "/projects/users/########/ehf_icf_all_county_annual.sas7bdat", clear
import sas using "/projects/users/########/ehf_icf_all_county_annual23.sas7bdat", clear

merge 1:1 ctyfips year using "/projects/users/########/CountyLevelWindDatabase.dta"
drop if _merge ==2
replace p_year = 0 if _merge==1
replace c_tcap = 0 if _merge==1
replace c_tnum = 0 if _merge==1
replace c_tp_cap = 0 if _merge==1
replace c_tp_tnum = 0 if _merge==1
replace c_ptnum = 0 if _merge==1
replace c_pcap = 0 if _merge==1
replace c_capx = 0 if _merge==1
replace ct_capx = 0 if _merge==1

drop cnty
egen cnty = group(ctyfips)
xtset cnty year

gen cy_tcap = c_tcap if p_year!=.
replace cy_tcap = 0 if p_year ==.

gen stfips = substr(ctyfips,1,2)

gen total_emp = total_wrkrs - total_unemp_wrkrs
*gen total_white_emp = tot_white_wrkrs - tot_white_unemp
*gen total_nonwhite_emp = tot_nonwhite_wrkrs - tot_nonwhite_unemp

save "/projects/users/########/CountyLevelWindWrkrs23.dta", replace

